import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { InspectionitemVO, InspectionitemForm, InspectionitemQuery } from '@/api/facility/inspection/inspection-item/types';

/**
 * 查询巡检项配置列表
 * @param query
 * @returns {*}
 */

export const listInspectionitem = (query?: InspectionitemQuery): AxiosPromise<InspectionitemVO[]> => {
  return request({
    url: '/inspection/inspectionItem/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询巡检项配置详细
 * @param patrolInspectionItemId
 */
export const getInspectionitem = (patrolInspectionItemId: string | number): AxiosPromise<InspectionitemVO> => {
  return request({
    url: '/inspection/inspectionItem/' + patrolInspectionItemId,
    method: 'get'
  });
};

/**
 * 新增巡检项配置
 * @param data
 */
export const addInspectionitem = (data: InspectionitemForm) => {
  return request({
    url: '/inspection/inspectionItem',
    method: 'post',
    data: data
  });
};

/**
 * 修改巡检项配置
 * @param data
 */
export const updateInspectionitem = (data: InspectionitemForm) => {
  return request({
    url: '/inspection/inspectionItem',
    method: 'put',
    data: data
  });
};

/**
 * 删除巡检项配置
 * @param patrolInspectionItemId
 */
export const delInspectionitem = (patrolInspectionItemId: string | number | Array<string | number>) => {
  return request({
    url: '/inspection/inspectionItem/' + patrolInspectionItemId,
    method: 'delete'
  });
};

/**
 * 巡检项配置+左侧树
 */
export const treeList = () => {
  return request({
    url: '/equipment/equipment-type/treeList',
    method: 'get'
  });
};

/**
 * 巡检项配置-左侧选项
 */
export const pointList = () => {
  return request({
    url: '/inspection/inspectionItem/getPointList',
    method: 'get'
  });
};
